/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "offer_day")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OfferDay.findAll", query = "SELECT o FROM OfferDay o"),
    @NamedQuery(name = "OfferDay.findByIdOfferDay", query = "SELECT o FROM OfferDay o WHERE o.offerDayPK.idOfferDay = :idOfferDay"),
    @NamedQuery(name = "OfferDay.findByIdOffer", query = "SELECT o FROM OfferDay o WHERE o.offerDayPK.idOffer = :idOffer"),
    @NamedQuery(name = "OfferDay.findByDay", query = "SELECT o FROM OfferDay o WHERE o.day = :day")})
public class OfferDay implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OfferDayPK offerDayPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DAY")
    @Temporal(TemporalType.DATE)
    private Date day;
    @JoinColumn(name = "ID_OFFER", referencedColumnName = "ID_OFFER", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Offer offer;

    public OfferDay() {
    }

    public OfferDay(OfferDayPK offerDayPK) {
        this.offerDayPK = offerDayPK;
    }

    public OfferDay(OfferDayPK offerDayPK, Date day) {
        this.offerDayPK = offerDayPK;
        this.day = day;
    }

    public OfferDay(int idOfferDay, int idOffer) {
        this.offerDayPK = new OfferDayPK(idOfferDay, idOffer);
    }

    public OfferDayPK getOfferDayPK() {
        return offerDayPK;
    }

    public void setOfferDayPK(OfferDayPK offerDayPK) {
        this.offerDayPK = offerDayPK;
    }

    public Date getDay() {
        return day;
    }

    public void setDay(Date day) {
        this.day = day;
    }

    public Offer getOffer() {
        return offer;
    }

    public void setOffer(Offer offer) {
        this.offer = offer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (offerDayPK != null ? offerDayPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OfferDay)) {
            return false;
        }
        OfferDay other = (OfferDay) object;
        if ((this.offerDayPK == null && other.offerDayPK != null) || (this.offerDayPK != null && !this.offerDayPK.equals(other.offerDayPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.OfferDay[ offerDayPK=" + offerDayPK + " ]";
    }
    
}
